package com.aoplog.demo.controller;

import com.aoplog.demo.annotation.CustomerAnnotationLog;
import com.aoplog.demo.entity.Person;
import com.aoplog.demo.service.PersonService;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zcx
 * @Title 测试控制类
 * @date 2019年01月24日 16:43
 **/
@RestController
public class DataController {

    @Autowired
    private PersonService personService;

    @CustomerAnnotationLog(descp = "插入用户信息",include = "{name}")
    @RequestMapping("/log/{name}")
    public void userInfo(@PathVariable("name") String name) {
        Person person = new Person();
        person.setId("7");
        person.setAge(27);
        person.setName("zm");
        person.setAddress("FZ");
        personService.insert(person);
    }

    @CustomerAnnotationLog(descp = "获取用户信息",include = "",a = "1")
    @RequestMapping(value = "/log/user",method = RequestMethod.GET,produces = "application/json")
    public Person getUserInfo(String m) {
        return personService.selectUser();
    }

    @CustomerAnnotationLog(descp = "根据id获取用户信息",include = "person")
    @RequestMapping(value = "/log/id",method = RequestMethod.GET,produces = "application/json")
    public Person getUser(Person person,HttpServletRequest request) {
        return personService.findUser(person);
    }

    @RequestMapping(value = "/log/update",method = RequestMethod.GET)
    public int updateUser() {
        Person person = new Person();
        person.setId("18");
        return personService.update(person);
    }

    @RequestMapping(value = "/log/test",method = RequestMethod.GET)
    public Person test() {
        Person person = new Person();
        person.setId("18");
        return person;
    }
}
